home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / KeyMap.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  2.0 KB  |  92 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1992 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Originator: Kent Sandvik
  5.   Date: 9/20/92
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TKeyMap is a KeyMap utility class.
  9.   TKeyMap.cp contains the member functions for the TKeyMap class.
  10.   _________________________________________________________________________________________________________ */
  11.  
  12. #ifndef _KEYMAP_
  13. #include "KeyMap.h"
  14. #endif
  15.  
  16.  
  17. // _________________________________________________________________________________________________________ //
  18. // TProcess class member function implementations
  19.  
  20. //    CONSTRUCTORS & DESTRUCTORS
  21.  
  22. #pragma segment KeyMap
  23. TKeyMap::TKeyMap()
  24. // Main constructor, empty for the time being.
  25. {
  26. }
  27.  
  28.  
  29. #pragma segment KeyMap
  30. TKeyMap::~TKeyMap()
  31. // Main destructor, empty for the time being.
  32. {
  33. }
  34.  
  35.  
  36. //     MAIN INTERFACES
  37. #pragma segment KeyMap
  38. Boolean TKeyMap::OptionKeyDown()
  39. // Return true if option key is down.
  40. {
  41.     ::GetKeys(fKeyMap);                            // get info
  42.     if (fKeyMap[1] & 4)
  43.         return true;
  44.     else
  45.         return false;
  46. }
  47.  
  48. #pragma segment KeyMap
  49. Boolean TKeyMap::CommandKeyDown()
  50. // Return true if command (Apple) key is down.
  51. {
  52.     ::GetKeys(fKeyMap);                            // get info
  53.     if (fKeyMap[1] & 0x8000)
  54.         return true;
  55.     else
  56.         return false;
  57. }
  58.  
  59.  
  60. #pragma segment KeyMap
  61. Boolean TKeyMap::ShiftKeyDown()
  62. // Return true if shift key is down.
  63. {
  64.     ::GetKeys(fKeyMap);                            // get info
  65.     if (fKeyMap[1] & 1)
  66.         return true;
  67.     else
  68.         return false;
  69. }
  70.  
  71.  
  72. // Fast macro for testing key codes.
  73. #define KeyCode(x,y) (BitTst(&(x), (y) ^ 0x07))
  74.  
  75.  
  76. #pragma segment KeyMap
  77. Boolean TKeyMap::IsKeyDown(unsigned short key)
  78. // Return true if key defined is down.
  79. {
  80.     ::GetKeys(fKeyMap);                            // get info
  81.     return (KeyCode(fKeyMap, key));
  82. }
  83.  
  84.  
  85. // _________________________________________________________________________________________________________ //
  86.  
  87.  
  88. /*    Change History (most recent last):
  89.   No        Init.    Date        Comment
  90.   1            khs        9/20/92        New file
  91. */
  92.